package com.java.java8.util.functioninterfacedemo;

import java.util.function.*;

/**
 * @author liyanhao
 * @Date 2023-03-29 19:01
 */
public class FunctionsDemo {

    public static void main(String[] args) {
//        intBinaryOperator();
//        IntConsumer();
//        intFunction();
//        intPredicate();
//        intSupplier();
//        intToDoubleFunction();
//        intToLongFunction();
//        intUnaryOperator();
//        longBinaryOperator();
//        longConsumer();


    }

    private static void longConsumer() {
        LongConsumer longConsumer = t -> System.out.println(t);
        longConsumer.accept(10000L);
    }

    private static void longBinaryOperator() {
        LongBinaryOperator longBinaryOperator = (t, u) -> Long.valueOf(t * u);
        System.out.println(longBinaryOperator.applyAsLong(10, 3));
    }

    private static void intUnaryOperator() {
        IntUnaryOperator intUnaryOperator = t -> t * 10;
        System.out.println(intUnaryOperator.applyAsInt(10));
    }

    private static void intToLongFunction() {
        IntToLongFunction intToLongFunction = (i) -> Long.valueOf(i);
        System.out.println(intToLongFunction.applyAsLong(10));
    }

    private static void intToDoubleFunction() {
        IntToDoubleFunction intToDoubleFunction = t -> 0.1 * t;
        System.out.println(intToDoubleFunction.applyAsDouble(1000));
    }

    private static void intSupplier() {
        IntSupplier intSupplier = () -> 10;
        System.out.println(intSupplier.getAsInt());
    }

    private static void intPredicate() {
        IntPredicate intPredicate = t -> false;
        System.out.println(intPredicate.test(10));
    }

    private static void intFunction() {
        IntFunction<Double> intFunction = (t) -> 0.1 * t;
        System.out.println(intFunction.apply(100));
    }

    private static void IntConsumer() {
        IntConsumer intConsumer = (t) -> System.out.println(t);
        intConsumer.accept(10);
    }

    private static void intBinaryOperator() {
        IntBinaryOperator intBinaryOperator = (u, t) -> u * t;
        int i = intBinaryOperator.applyAsInt(5, 2);
        System.out.println(i);
    }


}
